package com.sam.widget.headerBar;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;

import com.sam.widget.R;
import button.StateImageButton;


public class LeftImgTitleBar extends BaseTitleBar {
    private Drawable leftImgSrc,leftImgBg;
    private StateImageButton leftImgBtn;
    public LeftImgTitleBar(Context context) {
        super(context);
    }

    public LeftImgTitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public LeftImgTitleBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void getAttrs(AttributeSet attrs) {
        super.getAttrs(attrs);
        TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.LeftImgTitleBar);
        leftImgSrc=ta.getDrawable(R.styleable.LeftImgTitleBar_leftImgSrc);
        leftImgBg=ta.getDrawable(R.styleable.LeftImgTitleBar_leftImgBg);

        ta.recycle();
    }

    @Override
    protected void findView() {
        super.findView();
        leftImgBtn = new StateImageButton(context);
    }

    @Override
    protected void initView() {
        super.initView();
        if (leftImgSrc!=null) leftImgBtn.setImageDrawable(leftImgSrc);
        if (leftImgBg!=null)   leftImgBtn.setBackgroundDrawable(leftImgBg);
    }


    @Override
    public View getLeftView() {
        return leftImgBtn;
    }

}
